home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / Complete T233917242001.psc / TEST.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-07-21  |  15.5 KB  |  458 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  3. Object = "*\Atextbox.vbp"
  4. Begin VB.Form frmTest 
  5.    BackColor       =   &H80000004&
  6.    Caption         =   "CodeBox"
  7.    ClientHeight    =   4575
  8.    ClientLeft      =   165
  9.    ClientTop       =   450
  10.    ClientWidth     =   6360
  11.    BeginProperty Font 
  12.       Name            =   "Tahoma"
  13.       Size            =   8.25
  14.       Charset         =   0
  15.       Weight          =   400
  16.       Underline       =   0   'False
  17.       Italic          =   0   'False
  18.       Strikethrough   =   0   'False
  19.    EndProperty
  20.    Icon            =   "TEST.frx":0000
  21.    LinkTopic       =   "Form1"
  22.    ScaleHeight     =   4575
  23.    ScaleWidth      =   6360
  24.    StartUpPosition =   2  'CenterScreen
  25.    Begin VB.FileListBox FIL 
  26.       Height          =   870
  27.       Hidden          =   -1  'True
  28.       Left            =   3735
  29.       Pattern         =   "*.exe"
  30.       System          =   -1  'True
  31.       TabIndex        =   4
  32.       Top             =   2385
  33.       Visible         =   0   'False
  34.       Width           =   465
  35.    End
  36.    Begin VB.Timer tPOP 
  37.       Enabled         =   0   'False
  38.       Interval        =   100
  39.       Left            =   720
  40.       Top             =   3780
  41.    End
  42.    Begin VB.PictureBox P2 
  43.       AutoRedraw      =   -1  'True
  44.       AutoSize        =   -1  'True
  45.       Height          =   300
  46.       Left            =   1440
  47.       Picture         =   "TEST.frx":0E42
  48.       ScaleHeight     =   240
  49.       ScaleWidth      =   240
  50.       TabIndex        =   2
  51.       Top             =   3735
  52.       Visible         =   0   'False
  53.       Width           =   300
  54.    End
  55.    Begin VB.PictureBox Picture1 
  56.       AutoRedraw      =   -1  'True
  57.       BorderStyle     =   0  'None
  58.       Height          =   2625
  59.       Left            =   990
  60.       ScaleHeight     =   2625
  61.       ScaleWidth      =   1275
  62.       TabIndex        =   1
  63.       Top             =   675
  64.       Width           =   1275
  65.       Begin VB.ComboBox cbCon 
  66.          Height          =   315
  67.          Left            =   0
  68.          TabIndex        =   3
  69.          Top             =   0
  70.          Width           =   5370
  71.       End
  72.       Begin CodeBoxLib.CodeBox CodeBox1 
  73.          Height          =   5235
  74.          Left            =   450
  75.          TabIndex        =   0
  76.          Top             =   315
  77.          Width           =   5685
  78.          _ExtentX        =   10028
  79.          _ExtentY        =   9234
  80.       End
  81.       Begin VB.Line Line1 
  82.          Visible         =   0   'False
  83.          X1              =   345
  84.          X2              =   345
  85.          Y1              =   0
  86.          Y2              =   1305
  87.       End
  88.    End
  89.    Begin MSComDlg.CommonDialog CD 
  90.       Left            =   360
  91.       Top             =   1395
  92.       _ExtentX        =   847
  93.       _ExtentY        =   847
  94.       _Version        =   393216
  95.       CancelError     =   -1  'True
  96.       Color           =   8388608
  97.       DefaultExt      =   "java"
  98.       DialogTitle     =   "JEditor"
  99.       Filter          =   "Java source code (*.java)|*.java"
  100.       InitDir         =   "E:\JDK 1.3\bin"
  101.    End
  102.    Begin VB.Menu mnuEdit 
  103.       Caption         =   "&Edit"
  104.       Begin VB.Menu mnuEditUndo 
  105.          Caption         =   "&Undo"
  106.          Enabled         =   0   'False
  107.          Shortcut        =   ^Z
  108.       End
  109.       Begin VB.Menu mnuEditRedo 
  110.          Caption         =   "&Redo"
  111.          Enabled         =   0   'False
  112.          Shortcut        =   ^Y
  113.       End
  114.       Begin VB.Menu mnuEditSep1 
  115.          Caption         =   "-"
  116.       End
  117.       Begin VB.Menu mnuEditCut 
  118.          Caption         =   "&Cut"
  119.          Enabled         =   0   'False
  120.          Shortcut        =   ^X
  121.       End
  122.       Begin VB.Menu mnuEditCopy 
  123.          Caption         =   "C&opy"
  124.          Enabled         =   0   'False
  125.          Shortcut        =   ^C
  126.       End
  127.       Begin VB.Menu mnuEditPaste 
  128.          Caption         =   "&Paste"
  129.          Shortcut        =   ^V
  130.       End
  131.       Begin VB.Menu mnuEditSep2 
  132.          Caption         =   "-"
  133.       End
  134.       Begin VB.Menu mnuEditSave 
  135.          Caption         =   "&Save"
  136.          Shortcut        =   ^S
  137.       End
  138.       Begin VB.Menu mnuEditOpen 
  139.          Caption         =   "&Open"
  140.          Shortcut        =   ^O
  141.       End
  142.       Begin VB.Menu mnuEdtSep3 
  143.          Caption         =   "-"
  144.       End
  145.       Begin VB.Menu mnuEditExit 
  146.          Caption         =   "E&xit"
  147.       End
  148.    End
  149.    Begin VB.Menu mnuCode 
  150.       Caption         =   "&Code"
  151.       Visible         =   0   'False
  152.       Begin VB.Menu mnuCodeMethods 
  153.          Caption         =   "&Methods"
  154.          Begin VB.Menu mnuCodeMethodObj 
  155.             Caption         =   ""
  156.             Index           =   0
  157.          End
  158.       End
  159.       Begin VB.Menu mnuCodeVars 
  160.          Caption         =   "&Properties"
  161.          Begin VB.Menu mnuCodeVarsObj 
  162.             Caption         =   ""
  163.             Index           =   0
  164.          End
  165.       End
  166.    End
  167.    Begin VB.Menu mnuScript 
  168.       Caption         =   "&Script"
  169.       Begin VB.Menu mnuScriptImports 
  170.          Caption         =   "&Imports..."
  171.       End
  172.       Begin VB.Menu mnuStats 
  173.          Caption         =   "&Statistics"
  174.       End
  175.       Begin VB.Menu mnuSepDamn 
  176.          Caption         =   "-"
  177.       End
  178.       Begin VB.Menu mnuCompile 
  179.          Caption         =   "&Compile..."
  180.       End
  181.       Begin VB.Menu mnuExternal 
  182.          Caption         =   "&External"
  183.          Begin VB.Menu mnuExternalApp 
  184.             Caption         =   ""
  185.             Index           =   0
  186.          End
  187.       End
  188.       Begin VB.Menu asd 
  189.          Caption         =   "-"
  190.       End
  191.       Begin VB.Menu mnuDOS 
  192.          Caption         =   "&DOS Shell"
  193.       End
  194.    End
  195.    Begin VB.Menu mnuHelp 
  196.       Caption         =   "&Help"
  197.       Begin VB.Menu mnuHelpInfo 
  198.          Caption         =   "&Information..."
  199.       End
  200.    End
  201. Attribute VB_Name = "frmTest"
  202. Attribute VB_GlobalNameSpace = False
  203. Attribute VB_Creatable = False
  204. Attribute VB_PredeclaredId = True
  205. Attribute VB_Exposed = False
  206. 'TextBox Demo originally by Rang3r from SC4F
  207. 'Edited and improvised by Sushant Pandurangi
  208. 'I have a knack for editing things, you might think.
  209. 'Please also see the CoolMenu thing for icons in menus
  210. 'All that and more on http://sushantshome.tripod.com
  211. Option Explicit
  212. Dim Words As String, Errors As String
  213. Dim Color As Long, OpColor As Long
  214. Dim InSLComment As Boolean, InMLComment As Boolean
  215. Dim bWaitingComment As Boolean, bWaitingCommentClose As Boolean
  216. Private Declare Function FillRect Lib "user32" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long
  217. Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
  218. Private Const JDKDir = "e:\jdk 1.3\bin" 'change this
  219. Private Type RECT
  220.    Left As Long
  221.    Top As Long
  222.    Right As Long
  223.    Bottom As Long
  224. End Type
  225. Private Const ColourVars = "black blue cyan darkGray gray green lightGray magenta orange pink red white yellow"
  226. Private Const ColourFuncs = "brighter createContext darker decode equals getAlpha getBlue getColor getColorComponents getColorSpace getComponents getGreen getHSBColor getRed getRGB getRGBColorComponents getRGBComponents getTransparency hashCode HSBtoRGB RGBtoHSB toString"
  227. Private Sub CodeBox1_KeyDown(ASCII As Integer)
  228. On Error Resume Next
  229. If ASCII = vbKeyUp Or ASCII = vbKeyDown Then
  230.     If InStr(1, CodeBox1.CurrentLine, "//") > CodeBox1.CaretPixelX + 1 Or InStr(1, CodeBox1.CurrentLine, "//") = 0 Then
  231.         InSLComment = False
  232.     Else
  233.         InSLComment = True
  234.     End If
  235. End If
  236. End Sub
  237. Private Sub Form_Load()
  238. On Error Resume Next
  239.     Words = " private public int char void new return class String extends implements throws import final static true false if else while do for this try catch float long double boolean single synchronized instanceof "
  240.     Errors = " NoClassDefFoundException NullPointerException FileNotFoundException IOException "
  241.     Color = vbBlue
  242.     OpColor = vbRed
  243.     ChDir App.Path
  244.     CodeBox1.Load "readme.txt"
  245.     AddContents
  246.     AddColourItems
  247.     LoadExternals
  248. End Sub
  249. Private Sub Form_Resize()
  250. On Error Resume Next
  251. Picture1.Move 0, 0, ScaleWidth, ScaleHeight
  252. CodeBox1.Move 0, 330, Picture1.ScaleWidth, Picture1.ScaleHeight - 330
  253. cbCon.Move 0, 0, CodeBox1.Width
  254. Line1.Y2 = Picture1.ScaleHeight
  255. End Sub
  256. Private Sub mnuCodeMethodObj_Click(Index As Integer)
  257. CodeBox1.SelText = mnuCodeMethodObj(Index).Caption
  258. End Sub
  259. Private Sub mnuCodeVarsObj_Click(Index As Integer)
  260. CodeBox1.SelText = mnuCodeVarsObj(Index).Caption
  261. End Sub
  262. Private Sub mnuCompile_Click()
  263. On Error Resume Next
  264. If CD.FileName = "" Then MsgBox "Please save the file first.", vbExclamation: Exit Sub
  265. Shell FullPath(JDKDir, "javac.exe -verbose ") & Chr(34) & CD.FileName & Chr(34), vbNormalFocus
  266. End Sub
  267. Private Sub mnuDOS_Click()
  268. On Error GoTo hell
  269. Shell "C:\command.com", vbNormalFocus
  270. Exit Sub
  271. hell:
  272. MsgBox Error, vbExclamation
  273. End Sub
  274. Private Sub mnuEditExit_Click()
  275. End Sub
  276. Private Sub mnuEditOpen_Click()
  277. On Error GoTo hell
  278. CD.ShowOpen
  279. CodeBox1.Load CD.FileName
  280. InMLComment = False: InSLComment = False
  281. AddContents
  282. hell:
  283. End Sub
  284. Private Sub mnuEditPaste_Click()
  285. On Error Resume Next
  286. Dim strs As String, s() As String, i As Long
  287. strs = Clipboard.GetText(vbCFText)
  288. strs = Replace(strs, Chr(10), "")
  289. s = Split(strs, Chr(13))
  290. For i = 0 To UBound(s)
  291. CodeBox1.SelText = s(i) & vbCr
  292. Next i
  293. End Sub
  294. Private Sub mnuEditSave_Click()
  295. On Error GoTo hell
  296. CD.ShowSave
  297. CodeBox1.Save CD.FileName
  298. hell:
  299. End Sub
  300. Private Sub codebox1_CanPopup()
  301. PopupMenu mnuEdit
  302. End Sub
  303. Private Sub codebox1_KeyPress(ASCII As Integer)
  304. If Chr$(ASCII) = "/" And Not bWaitingComment And Not InMLComment Then bWaitingComment = True: Exit Sub
  305. If Chr$(ASCII) = "/" And bWaitingComment Then bWaitingComment = False: InSLComment = True: Exit Sub
  306. If ASCII = 13 And InSLComment = True Then InSLComment = False: Exit Sub
  307. If Chr$(ASCII) = "*" And bWaitingComment Then InMLComment = True: bWaitingComment = False: Exit Sub
  308. If Chr$(ASCII) = "*" And InMLComment Then bWaitingCommentClose = True: Exit Sub
  309. If Chr$(ASCII) = "/" And InMLComment And bWaitingCommentClose Then InMLComment = False: bWaitingCommentClose = False: Exit Sub
  310. bWaitingComment = False: bWaitingCommentClose = False
  311. End Sub
  312. Private Sub codebox1_MoveCaret(Column As Long, Row As Long)
  313. Caption = "TextBox Demo: Col " & Column & ", Line " & Row
  314. Refresh
  315. End Sub
  316. Private Sub codebox1_Word(Word As CodeBoxLib.TextWord, NewLine As Boolean)
  317. If Word Is Nothing Then Exit Sub
  318.     On Error Resume Next
  319.         If Right(Word.Word, 6) = "Color." Then
  320.             MousePointer = 11
  321.             tPOP.Enabled = True
  322.         End If
  323.         If InStr(Words, " " + (Word.Word) + " ") > 0 Then
  324.             Word.Color = Color
  325.             Word.KeyWord = True
  326.         ElseIf InStr(Errors, " " + Word.Word + " ") Then
  327.             Word.KeyWord = True
  328.             Word.Color = vbRed
  329.         Else
  330.             Word.Color = CodeBox1.ForeColor
  331.         End If
  332.         If IsNumeric(Word.Word) Then Word.Color = 32768 'numbers
  333.         If Left(Trim(Word.Word), 2) = "/*" Then InMLComment = True
  334.         If Right(Trim(Word.Word), 2) = "*/" Then InMLComment = False: Word.Color = 128: Exit Sub
  335.         If InMLComment Or InSLComment Then Word.Color = 128: Exit Sub
  336.         If Left(Word.Word, 12) = "sushantshome" Then Word.Color = vbRed
  337. End Sub
  338. Function Spruce(lpStr As String) As String
  339. Dim l As Long
  340. 'spruce up the string nice and shiny
  341. lpStr = Replace(lpStr, Chr(10), "")
  342. lpStr = Replace(lpStr, Chr(13), "")
  343. lpStr = Replace(lpStr, vbTab, Space(1))
  344. l = InStr(1, lpStr, "//")
  345. If l Then Mid$(lpStr, l, Len(lpStr) - l) = Space$(l)
  346. lpStr = Replace(lpStr, "  ", " ")
  347. Loop While InStr(1, lpStr, "  ")
  348. Spruce = lpStr
  349. End Function
  350. Sub AddColourItems()
  351. On Error Resume Next
  352. Dim CL() As String, i As Long
  353. CL = Split(ColourFuncs, " ")
  354. For i = 0 To UBound(CL)
  355. Load mnuCodeMethodObj(i)
  356. mnuCodeMethodObj(i).Caption = CL(i)
  357. Next i
  358. CL = Split(ColourVars, " ")
  359. For i = 0 To UBound(CL)
  360. Load mnuCodeVarsObj(i)
  361. mnuCodeVarsObj(i).Caption = CL(i)
  362. Next i
  363. End Sub
  364. Private Sub mnuEditUndo_Click()
  365. On Error Resume Next
  366. cbCon.ZOrder vbBringToFront
  367. cbCon.SetFocus
  368. End Sub
  369. Private Sub mnuExternalApp_Click(Index As Integer)
  370. On Error Resume Next
  371. Dim params As String
  372. If CD.FileName = "" Then MsgBox "Please save the file first.", vbExclamation: Exit Sub
  373. params = InputBox$("This application can not be run without command line parameters. Please specify a command line parameter, or click OK to use the suggested one.", "Parameters", Chr(34) & CD.FileName & Chr(34))
  374. If params = "" Then Exit Sub
  375. Shell FullPath(JDKDir, mnuExternalApp(Index).Caption) & " " & params, vbNormalFocus
  376. End Sub
  377. Private Sub mnuHelpInfo_Click()
  378. On Error Resume Next
  379. Dim asd As String
  380. asd = FullPath(App.Path, "readme.txt")
  381. InMLComment = False: InSLComment = False
  382. CodeBox1.Load asd
  383. End Sub
  384. Private Sub mnuScriptImports_Click()
  385. On Error Resume Next
  386. Dim i As Long, s As String, mn As String
  387. Dim lEnd As Long
  388. s = CodeBox1.Text
  389. Do While InStr(i, s, "import ") > 0
  390. i = InStr(i + 1, s, "import ")
  391. If i = 0 Then Exit Do
  392. lEnd = InStr(i + 1, s, ";")
  393. If lEnd = 0 Then GoTo n
  394. mn = mn & Mid$(s, i + 7, lEnd - i - 7) & vbNewLine
  395. If mn = "" Then mn = "None."
  396. MsgBox "Imports:" & Space$(20) & vbNewLine & vbNewLine & mn, vbInformation, CD.FileTitle
  397. End Sub
  398. Private Sub mnuStats_Click()
  399. On Error Resume Next
  400. Dim s As String
  401. s = "This file contains " & CodeBox1.LineCount & " lines of code and " & cbCon.ListCount & " Members."
  402. s = s & vbNewLine & "Timestamp: " & FileDateTime(CD.FileName)
  403. s = s & " (" & Round(FileLen(CD.FileName) / 1024, 2) & " KB file)"
  404. MsgBox s, vbInformation
  405. End Sub
  406. Private Sub tPOP_Timer()
  407. On Error Resume Next
  408. SetCursorPos Left / 15 + CodeBox1.CaretPixelX, Top / 15 + 930 / 15 + CodeBox1.CaretPixelY + 22
  409. PopupMenu mnuCode, vbPopupMenuCenterAlign, CodeBox1.CaretPixelX * 15, ((CodeBox1.CaretPixelY + 16) * 15) + 330
  410. MousePointer = 0
  411. tPOP.Enabled = False
  412. End Sub
  413. Sub AddContents()
  414. On Error Resume Next
  415. cbCon.Clear
  416. Dim i As Long, s As String
  417. Dim pub As Long, pri As Long
  418. Dim lEnd As Long
  419. s = CodeBox1.Text
  420. Do While InStr(i, s, "public ") > 0
  421. i = InStr(i + 1, s, "public ")
  422. If i = 0 Then Exit Do
  423. lEnd = InStr(i + 1, s, "}")
  424. If lEnd = 0 Then lEnd = Len(s)
  425. If InStr(i + 1, s, ";") < lEnd Then lEnd = InStr(i + 1, s, ";")
  426. If InStr(i + 1, s, vbNewLine) < lEnd Then lEnd = InStr(i + 1, s, vbNewLine)
  427. If InStr(i + 1, s, "=") < lEnd Then lEnd = InStr(i + 1, s, "=")
  428. If lEnd = 0 Then Exit Do
  429. cbCon.AddItem Trim$(Mid$(s, i, lEnd - i))
  430. pub = pub + 1
  431. i = 0
  432. Do While InStr(i, s, "private ") > 0
  433. i = InStr(i + 1, s, "private ")
  434. If i = 0 Then Exit Do
  435. lEnd = InStr(i + 1, s, "}")
  436. If lEnd = 0 Then lEnd = Len(s)
  437. If InStr(i + 1, s, ";") < lEnd Then lEnd = InStr(i + 1, s, ";")
  438. If InStr(i + 1, s, vbNewLine) < lEnd Then lEnd = InStr(i + 1, s, vbNewLine)
  439. If InStr(i + 1, s, "=") < lEnd Then lEnd = InStr(i + 1, s, "=")
  440. If lEnd = 0 Then Exit Do
  441. cbCon.AddItem Trim$(Mid$(s, i, lEnd - i))
  442. pri = pri + 1
  443. cbCon.Text = pub & " Public, " & pri & " Private Methods and Properties - " & CD.FileTitle
  444. End Sub
  445. Sub LoadExternals()
  446. On Error Resume Next
  447. FIL.Path = JDKDir
  448. Dim i As Long
  449. For i = 0 To FIL.ListCount - 1
  450. Load mnuExternalApp(i)
  451. mnuExternalApp(i).Caption = FIL.List(i)
  452. Next i
  453. End Sub
  454. Function FullPath(lpPath As String, lpFile As String) As String
  455. If Right(lpPath, 1) <> "\" Then lpPath = lpPath & "\"
  456. FullPath = lpPath & lpFile
  457. End Function
  458.